package com.zhangliuliu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhangliuliu.bean.ExpertBean;
import com.zhangliuliu.service.ExpertService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("expert")
public class expertController {
    @Resource
    private ExpertService expertService;

    @RequestMapping("add")
    @ResponseBody
    void addExpert(ExpertBean expertBean){
        expertService.addExpert(expertBean);
    }
    @RequestMapping("select")
    @ResponseBody
    ExpertBean getOne(int id){
        return expertService.getOne(id);
    }
    @RequestMapping("update")
    @ResponseBody
    void updateExpert(@RequestParam("id") int id,@RequestParam("tell") String tell,
                      @RequestParam("post")String post,
                      @RequestParam("unit")String unit, @RequestParam("mail")String mail){
        expertService.updateExpert(id,tell,post,unit,mail);
    }
    @RequestMapping("cutByItem")
    @ResponseBody
    IPage<ExpertBean> cutByItem(@RequestParam(value = "pageNO",defaultValue = "1") int pageNo,
                                @RequestParam(value = "pageSize",defaultValue = "4") int pageSize,
                                @RequestParam("name") String name,
                                @RequestParam("good") String good,
                                @RequestParam("unit") String unit){
 return expertService.cutByItem(pageNo,pageSize,name,good,unit);}

    @RequestMapping("del")
    @ResponseBody
     void del(int id){
            expertService.del(id);
        }
}

